package com.copa.l303;

/**
 * @author copa
 * @createDate 2022-09-06 11:45
 * @function 暴力法
 */
public class Test1 {

    private int[] nums;

    public Test1(int[] nums) {
        this.nums = nums;
    }

    public int sumRange(int left, int right) {
        int result = 0;
        for (int i = left; i <= right; i++) {
            result+= nums[i];
        }
        return result;
    }

    /**
     * Your NumArray object will be instantiated and called as such:
     * NumArray obj = new NumArray(nums);
     * int param_1 = obj.sumRange(left,right);
     */
    public static void main(String[] args) {
        int[] nums = {-2, 0, 3, -5, 2, -1};
        Test1 test1 = new Test1(nums);
        System.out.println(test1.sumRange(0, 2));
        System.out.println(test1.sumRange(2, 5));
        System.out.println(test1.sumRange(0, 5));

    }
}

